/*
 * @Author: yangzonglong
 * @Date: 2021-03-05 12:08:36
 * @version: v1.0.0
 * @Descripttion:
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-08-31 09:47:44
 * @Auditor:
 */
import React, { useState, useEffect } from 'react';
import PrintItem from './../PrintItem';

const App = (props,) => {
  const { formItemProps, initialValue, inputProps } = props;

  const [v, setV] = useState({});

  useEffect(() => {
    if (initialValue && Array.isArray(initialValue)) setV(initialValue[0]);
    else if (initialValue && typeof initialValue === 'object') {
      setV(initialValue);
    }
  }, [initialValue]);

  return (
    <PrintItem
      style={formItemProps?.style || {}}
      label={localStorage.i18nextLng === 'en' ? formItemProps?.labelEn : formItemProps?.label}>
      {v?.[inputProps?.showFieldName] || ''}
    </PrintItem>
  );
};

export default App;
